package twitterdata;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Main2TwitterData {

	public static void main (String[]args) throws Exception{
		
		List<TwitterUser>t_use = new ArrayList<TwitterUser>();
		List<TwitterUser>t = new ArrayList<TwitterUser>();
		
	    String file2 = "C:/Users/Alket/codeindigo/FlickrAPI/FileLavoroAttuale/TotaleTS4AllUsers.txt";
		BufferedReader br = new BufferedReader(new FileReader(new File(file2)));
		TwitterUserMethods.readFileTwitter("C:/Users/Alket/codeindigo/FlickrAPI/TO_bbox/TwitterUsers3EventsTS2.csv", t);
		String linea = "";
		Map<Integer, List<Long>> map = new HashMap<Integer, List<Long>>();
		List<Long>tsp = new ArrayList<Long>();
		System.out.println("ciao");
		long ts = 0;
		
		TwitterUserMethods.loadList(tsp, "C:/Users/Alket/codeindigo/FlickrAPI/FileLavoroAttuale/TotaleTS4AllUsers.txt");
		Set<Long>set = new HashSet<Long>(tsp);
		List<Long> finallist = new ArrayList<Long>(set);
		
		for (int i = 0; i < finallist.size(); i++) {
			System.out.println(finallist.get(i).toString()+"*");
		}
		
		//for (int i = 0; i < set.size(); i++) {
		//	System.out.println(set);
		//}
		/*
		System.out.println("ciao");
		for (int i = 0; i < t.size(); i++) {
			tsplist = new ArrayList<Long>();
			
			long ts = t.get(i).ts;
			//System.out.println("**"+ts);
			 TwitterUserMethods.ts_pls_list4TwitterUser("C:/DATA/data/mese/DatiTotali", ts);
		//map.put(i, tsplist);
		}
		
		//Collections.sort(tsp);
		Set<Long> tspset = new HashSet<Long>(tsp);
		*/
		/*while((line = br.readLine())!=null){
		      
        	long ts = Long.parseLong(line);
			tsp.add(ts);
		}
		br.close();
		
		
		Collections.sort(tsp);
		Set<Long> tspset = new HashSet<Long>(tsp);
		
//		
		System.out.println(tspset.toString());
		*/
		
		
		/*
		Collections.sort(t_use);
		for (int i = 0; i < t_use.size(); i++) {
			System.out.println(t_use.get(i).user_id+","+t_use.get(i).lat+","+t_use.get(i).lon+","+t_use.get(i).ts);
		}
		TwitterUserMethods.printUsers("TwitterUsers3EventsTS2.csv", t_use);
		*/
		/*List<Integer>d = new ArrayList<Integer>();
		
		TwitterUserMethods.loadList(d, "C:/Users/Alket/codeindigo/FlickrAPI/StampaFreqTwitterEventsCounter.csv");
		Collections.sort(d);
		for (int i = 0; i < d.size(); i++) {
			//System.out.println(d.get(i));
		}
		String file = "TwitterSortedUsers.csv";
		//TwitterUserMethods.adjDate(file, t); 
		//Collections.sort(t);
		//TwitterUserMethods.printUsers("TwitterSortedUsersTs2.csv", t);
		
		PrintWriter out = new PrintWriter(new FileWriter("StampaFreqTwitterEventsCounter34.csv"));
		int counter = 1;
		for (int i = 1; i < d.size(); i++) {
		
			if(d.get(i)==d.get(i-1)){
				//System.out.println(d.get(i)+"-->"+d.get(i-1));
				counter++;
			//System.out.println(counter);
			}
			else{
				out.println(d.get(i-1)+","+counter);
			System.out.println(d.get(i-1)+","+counter);
			counter = 1;
			
			}
		
		}
		out.close();
		*/
		/*String inflow = "TwitterData2";
		 File Folder = new File(inflow);
		 File files[];
		 files = Folder.listFiles();
		
		 String s = "";
		//String line;
		
		//BufferedReader br = new BufferedReader(new FileReader(new File(file)));
		
		try{
	        String line = "";

            if(files.length>1)
            {
             for(int i = 0;i<files.length; i++){
               
               BufferedReader br = new BufferedReader(new FileReader(files[i]));
               System.out.print("reading...");
               System.out.println(files[i].getName()+", number: "+i);
               String filefullname = files[i].getName();
               PrintWriter out = 
            		   new PrintWriter(new FileWriter(new File(files[i].getName()+"number"+i+".csv")));
              
               /* while((line = br.readLine())!=null){
		      
                	line.trim();
        			System.out.println(line);
        			if(line.contains(",,,")){
        				//br.readLine();
        				continue;
        			}
        			else  s = line;
        			out.println(s);
        			
        		}
        	*/
       /*         while((line = br.readLine())!=null){
      		      
                	line.trim();
        			System.out.println(line);
        			if(line.startsWith("35") || line.startsWith("34")){
        				//br.readLine();
        				s = line;
            			out.println(s);
        			}
        			else  
        			continue;
        			
        		}
        		br.close();
        		out.close();
        		
            }
           }
		 }catch( Exception ex){
		    	ex.printStackTrace(); 
	  }
		
	*/
}
}
